﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<CognisessWeb.Models.NavigationModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Create
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>Create</h2>

    <% using (Html.BeginForm("Create", "Navigation", FormMethod.Post, new { id = "formMain" }))
       {%>
        <%= Html.ValidationSummary(true) %>

        <fieldset>
            <legend>Fields</legend>
            
            <div class="editor-label">
                <%= Html.LabelFor(model => model.TitleName) %>
            </div>
            <div class="editor-field">
                <%= Html.DropDownList("parentId", ViewData["parentId"] as SelectList)%><label id="lable1"></label>
            </div>
            
            
            <div class="editor-label">
                <%= Html.Label("NewTitleName") %>
            </div>
            <div class="editor-field">
                <%= Html.TextBoxFor(model => model.TitleName) %>
                <%= Html.ValidationMessageFor(model => model.TitleName) %>
                
            </div>
            
            <div class="editor-label">
                <%= Html.LabelFor(model => model.Type) %>
            </div>
            <div class="editor-field">
               <%= Html.DropDownList("type", ViewData["Type"] as SelectList) %><label id="label2"></label>
            </div>
            
            <div class="editor-label">
                <%= Html.LabelFor(model => model.Link) %>
            </div>
            <div class="editor-field">
                <%= Html.TextBoxFor(model => model.Link) %>
                <%= Html.ValidationMessageFor(model => model.Link) %>
            </div>
            
           
            
            <p>
                <input type="submit" value="Create" />
            </p>
        </fieldset>

    <% } %>

    <div>
        <%= Html.ActionLink("Back to List", "Index")%>
    </div>
<script language="javascript" type="text/javascript">
    $("#lable1").text("(Can Don't Select)");
    $("#parentId").change(function() {
    if ($("#parentId").val() == "0") {
        $("#lable1").text("");

    }
    if ($("#parentId").val() != "0") {
        $("#lable1").text("(Must Select the top or down type)");
        $("#lable2").text("(Must Select Type)");
    }
})

    $("#type").change(function() {
        if ($("#type").val() == "0") {
            $("#lable2").text("(Must Select Type)");
        }
        if ($("#type").val() != "2") {
            $("#lable2").text("(Must Select TitleName)");
        }
    })
    
        $("#formMain").validate({
            rules: {
            parentId: { digits: true },
            TitleName: { required: true, maxlength: 50 },
            type: { digits: true }
            },

            messages: {
            parentId: { digits: "Please Select an option ." },
            TitleName: { required: "Please enter your TitleName.", maxlength: "TitleName Length is not greater than 50." },
            type: { digits: "Please Select an option." }
            }

        });
        $(".field-validation-error").remove();
        

    $(function() {
        $('#BirthDate').datepicker({ duration: '', showTime: true, constrainInput: true });
    });
    </script>

    <style type="text/css">
        input[class="error"]
        {
            border: 1px solid #ff0000;
            background-color: #ffeeee;
        }
        Label[class="error"]
        {
            padding-left: 10px;
        }
    </style>
</asp:Content>

